# -*- coding=utf-8
from qcloud_cos import CosConfig
from qcloud_cos import CosS3Client
from qcloud_cos import CosServiceError
from qcloud_cos import CosClientError

import sys
import logging

secret_id = '填写自己的ID'
secret_key = '填写自己的密钥'
region = '填写自己的可用区'
new_Bucket = '填写自己的存储名称'

def PutDataQcloud(new_file_name, new_LocalFilePath):
    '''
		1、第一个参数：设置上传至腾讯云服务器的绝对路径
		2、第二个参数：设置本地上传文件的绝对路径
	'''
    logging.basicConfig(level=logging.INFO, stream=sys.stdout)
    token = None
    config = CosConfig(Region=region, SecretId=secret_id, SecretKey=secret_key, Token=token)
    client = CosS3Client(config)
    file_name = new_file_name

    response = client.upload_file(
        Bucket=new_Bucket,
        LocalFilePath=new_LocalFilePath,
        Key=file_name,
        PartSize=10,
        MAXThread=10
    )
    print(response['ETag'])